import useAppEnv from "@/hooks/use-app-env";
import { RouteRecordRaw } from "vue-router";

export interface ITabBarProps {
  /** 选中标签的颜色 */
  activeColor: string;
  /** 未选中标签的颜色 */
  inactiveColor: string;
  /** tabbar列表 */
  tabbarList: Array<{
    title: string;
    inactiveIcon: string;
    activeIcon: string;
    path: RouteRecordRaw["path"];
    name: RouteRecordRaw["name"];
    component: RouteRecordRaw["component"];
    keepAlive?: boolean;
  }>;
}

export interface IAppConfig {
  endpointCode: string;
  appKey: string;
  appId: string;
  /** 是否开启tabbar */
  openTabbar?: boolean;
  /** tabbar参数 */
  tabbar?: ITabBarProps;
  /** 是否http加解密 */
  useEncrypt?: boolean;
}

export enum Env {
  DEV = "dev",
  TEST = "test",
  PROD = "prod",
}

/** 测试环境应用配置信息 */
const testConfig: IAppConfig = {
  endpointCode: "end_AhADjzMCQM8t",
  appKey: "dsy_Wlep4Af6LPQf",
  appId: "wx52432dbad7e70e1b",
};
/** 开发环境应用配置信息 */
const devConfig: IAppConfig = {
  endpointCode: "end_QBnP7FLy3zxS",
  appKey: "dsy_bGHFcKlKvO9S",
  appId: "wx52432dbad7e70e1b",
};
/** 生产环境配置信息 */
const prodConfig: IAppConfig = {
  endpointCode: "end_6jDLQ7f3bYpH",
  appKey: "dsy_I6oQCb3c83UZ",
  appId: "wx948178e3ae34071a",
};

const config: IAppConfig = (() => {
  const { env } = useAppEnv();
  let config = devConfig;
  switch (env) {
    case Env.TEST:
      config = testConfig;
      break;
    case Env.PROD:
      config = prodConfig;
      break;
    default:
      config = devConfig;
      break;
  }
  return {
    ...config,
    openTabbar: false,
    tabbar: {
      inactiveColor: "#7D7E80",
      activeColor: "#E7572F",
      tabbarList: [
        {
          title: "首页",
          inactiveIcon: "home-o",
          activeIcon: "home-o",
          path: "/home",
          name: "home",
          component: () => import("@/views/home/index.vue"),
          keepAlive: false
        },
        {
          title: "我的",
          inactiveIcon: "friends-o",
          activeIcon: "friends-o",
          path: "/mine",
          name: "mine",
          component: () => import("@/views/mine/index.vue"),
          keepAlive: false
        },
      ],
    },
    useEncrypt: false,
  };
})();

export default config;
